package com.ali.common;

import java.time.LocalDate;
import java.time.Period;

public class PeriodUtil {
    /**
     * 获取相差年
     */
    public static long getBetweenYear(LocalDate localDate1, LocalDate localDate2) {
        return Period.between(localDate1, localDate2).getYears();
    }

    /**
     * 获取相差月
     */
    public static long getBetweenMonth(LocalDate localDate1, LocalDate localDate2) {
        return Period.between(localDate1, localDate2).getMonths();
    }

    /**
     * 获取相差日
     */
    public static long getBetweenDay(LocalDate localDate1, LocalDate localDate2) {
        return Period.between(localDate1, localDate2).getDays();
    }
}
